package thread.threaddemo;

/**
 * @Author: wenjingyuan
 * @Date: 2023/02/11/21:17
 * @Description:wait(0）VSsleep(0)
 */
public class WaitSleepDemo {
    public static void main(String[] args) {
        Object lock=new Object();
        Thread t1=new Thread(()->{
            synchronized (lock){
                System.out.println("线程1：开始执行");
                try {
                    lock.wait(0);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("线程1：结束执行");
            }
        },"wait0");
        t1.start();
        Thread t2=new Thread(()->{
            System.out.println("线程2：开始执行");
            try {
                Thread.sleep(0);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("线程2：结束执行");
        },"sleep0");
        t2.start();
    }
}
